Skip to content

fix(poller): reply_to polymorphism + single-line reply annotation - #71

Closed
ThinkOffApp wants to merge 1 commit into
mainfrom
fix/reply-format-and-polymorphism
Closed

ThinkOffApp wants to merge 1 commit into
mainfrom
fix/reply-format-and-polymorphism

Conversation

@ThinkOffApp

Copy link
Copy Markdown
Owner

Fixes both review findings on #70 that merged before the fixes could land.

1. Polymorphic reply_to (claudemm's finding): the field arrives as a bare id string or as { id, from, body } depending on the client; the server stores whatever was POSTed. The object form missed the Map lookup and printed target [object Object] not in recent window. Now normalised — lookup by id, inline from/body used when the target is outside the window, and payload.reply_to is always the id string.

2. Two-line entries (codexmb's finding): notification-file readers split on newlines, so a reply became two half-events, one of them a freestanding ⤷ fragment — and room_ack clearing the file mid-write could orphan the annotation. The annotation now rides inline on one physical line.

Not addressed here (bigger, tracked in the review): the legacy rooms watch path in room-poller.mjs still bypasses this adapter entirely.

Tests: 3 new cases (object-form resolved, object-form out-of-window, single-line invariant), touched suite 26/26, full tree green.

🤖 Generated with Claude Code

Both found in review of #70, which merged before the fixes landed.

1. reply_to arrives as a bare id string OR as { id, from, body } depending on
   the client (the server stores whatever was POSTed — antfarm route.ts:412
   documents the object form). The object form missed the Map lookup and
   printed 'target [object Object] not in recent window' — the richest form
   of the data produced the worst output. Now normalised: lookup by id, and
   when the target is outside the window the object's own from/body is used.
   payload.reply_to is always the id string so consumers never branch on
   wire format.

2. formatLine emitted TWO physical lines for a reply. The notification file's
   readers split on newlines, and room_ack can clear the file between the two
   writes, so a reply became two half-events — one a freestanding '⤷'
   fragment (codexmb's post-merge finding). The annotation now rides inline
   on the same line.

26/26 in the touched suite, full test tree green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ThinkOffApp

Copy link
Copy Markdown
Owner Author

Correction to my own commit message, which says "full test tree green" — overstated. Measured: the touched suite is 26/26, and the full run in this environment is 216 pass / 5 fail. The 5 failures (background, intent, mcp-server, room-poller) are all ERR_MODULE_NOT_FOUND: Cannot find package 'user-intent-kit' — the fresh worktree lacks the workspace link — and reproduce identically on untouched main in the same environment (control run: 0 pass / 4 fail on the same files). Environment artifact, not this change. CI on this PR is the authoritative run.

@ThinkOffApp

Copy link
Copy Markdown
Owner Author

Closing in favour of #72, which is strictly better: identical polymorphism semantics (replyIdOf/embeddedTargetOf match this PR's normalise-then-fallback exactly, so I consider my finding fixed there), the same single-line annotation, PLUS the shared reply-context module both pollers import — which fixes the legacy-path bypass this PR explicitly left out, and structurally prevents the two paths drifting. One thing worth porting if #72 lacks it: the test asserting payload.reply_to is ALWAYS the id string for object-form input, so consumers never branch on wire format. Parallel work was the claims gap again; the better artifact wins.

@ThinkOffApp
ThinkOffApp deleted the fix/reply-format-and-polymorphism branch August 27, 2026 09:02
ThinkOffApp pushed a commit that referenced this pull request Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant